package com.newtouch.cq.base.starter.business.model.dto;


import com.newtouch.cq.base.starter.business.model.vo.MenuVO;
import com.newtouch.cq.base.starter.lang.em.MenuTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
@Data
@ApiModel("菜单树")
public class MenuTree extends TreeNode {
	private static final long serialVersionUID = 1752145983760286984L;
    @ApiModelProperty("菜单图标")
	private String icon;
    @ApiModelProperty("请求链接（菜单的时候，前端URL）")
    private String url;
    @ApiModelProperty("spread")
    private boolean spread = false;
    @ApiModelProperty("path")
    private String path;
    @ApiModelProperty("VUE页面")
    private String component;
    @ApiModelProperty("authority")
    private String authority;
    @ApiModelProperty("redirect")
    private String redirect;
    @ApiModelProperty("菜单编码")
    private String code;
    @ApiModelProperty("类型 1：菜单 2：接口")
    private MenuTypeEnum type;
    @ApiModelProperty("label")
    private String label;
    @ApiModelProperty("排序")
    private Integer sort;

    public MenuTree() {
    }

    public MenuTree(long id, String name, long parentId) {
        this.id = id;
        this.parentId = parentId;
        this.name = name;
        this.label = name;
    }

    public MenuTree(long id, String name, MenuTree parent) {
        this.id = id;
        this.parentId = parent.getId();
        this.name = name;
        this.label = name;
    }

    public MenuTree(MenuVO menuVo) {
        this.id = menuVo.getId();
        this.parentId = menuVo.getParentId();
        this.icon = menuVo.getIcon();
        this.name = menuVo.getMenuName();
        this.url = menuVo.getUrl();
//        this.path = menuVo.getPath();
        this.component = menuVo.getComponent();
        this.type = menuVo.getType();
        this.label = menuVo.getMenuName();
        this.sort = menuVo.getSort();
    }
}
